package com.ruoyi.edit.service.impl;

import java.util.Date;
import java.util.List;

import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.edit.utils.UuidUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.edit.mapper.CourseAppendixMapper;
import com.ruoyi.edit.domain.CourseAppendix;
import com.ruoyi.edit.service.ICourseAppendixService;
import com.ruoyi.common.core.text.Convert;

/**
 * 课程附件Service业务层处理
 * 
 * @author qiufeng
 * @date 2022-09-07
 */
@Service
public class CourseAppendixServiceImpl implements ICourseAppendixService 
{
    @Autowired
    private CourseAppendixMapper courseAppendixMapper;

    /**
     * 查询课程附件
     * 
     * @param id 课程附件主键
     * @return 课程附件
     */
    @Override
    public CourseAppendix selectCourseAppendixById(String id)
    {
        return courseAppendixMapper.selectCourseAppendixById(id);
    }

    /**
     * 查询课程附件列表
     * 
     * @param courseAppendix 课程附件
     * @return 课程附件
     */
    @Override
    public List<CourseAppendix> selectCourseAppendixList(CourseAppendix courseAppendix)
    {
        return courseAppendixMapper.selectCourseAppendixList(courseAppendix);
    }

    /**
     * 新增课程附件
     * 
     * @param courseAppendix 课程附件
     * @return 结果
     */
    @Override
    public int insertCourseAppendix(CourseAppendix courseAppendix)
    {
        courseAppendix.setId(UuidUtil.getUuid());
        courseAppendix.setDeleted(0);
        courseAppendix.setCreated(new Date());
        courseAppendix.setCreatedBy(ShiroUtils.getLoginName());
        courseAppendix.setCreatedName(ShiroUtils.getName());
        return courseAppendixMapper.insertCourseAppendix(courseAppendix);
    }

    /**
     * 修改课程附件
     * 
     * @param courseAppendix 课程附件
     * @return 结果
     */
    @Override
    public int updateCourseAppendix(CourseAppendix courseAppendix)
    {
        return courseAppendixMapper.updateCourseAppendix(courseAppendix);
    }

    /**
     * 批量删除课程附件
     * 
     * @param ids 需要删除的课程附件主键
     * @return 结果
     */
    @Override
    public int deleteCourseAppendixByIds(String ids)
    {
        return courseAppendixMapper.deleteCourseAppendixByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除课程附件信息
     * 
     * @param id 课程附件主键
     * @return 结果
     */
    @Override
    public int deleteCourseAppendixById(String id)
    {
        return courseAppendixMapper.deleteCourseAppendixById(id);
    }
}
